
CC = gcc
COMPILE_FLAG = -O0 -Wall

SRC_DIRECTORY := src
BUILD_DIRECTORY := obj
INCLUDES := -I include 

LIBS = -lpthread

all: pthread_race pthread_race2 pthread_race3 pthread_term pthread_clean pthread_attribute pthread_account pthread_account_mutex \
	 pthread_mutex_type pthread_rwlock pthread_cond pthread_cond_multi pthread_productor_consumer pthread_sem_base \
	 pthread_account_sem pthread_count_sem pthread_deadlock pthread_signal pthread_cancel

pthread_race:
	@test -d $(BUILD_DIRECTORY) || mkdir $(BUILD_DIRECTORY)
	$(CC) -g -rdynamic $(INCLUDES)   $(COMPILE_FLAG)  -o $(BUILD_DIRECTORY)/pthread_race $(SRC_DIRECTORY)/pthread_race.c  $(LIBS) 

pthread_race2:
	@test -d $(BUILD_DIRECTORY) || mkdir $(BUILD_DIRECTORY)
	$(CC) -g -rdynamic $(INCLUDES)   $(COMPILE_FLAG)  -o $(BUILD_DIRECTORY)/pthread_race2 $(SRC_DIRECTORY)/pthread_race2.c  $(LIBS) 

pthread_race3:
	@test -d $(BUILD_DIRECTORY) || mkdir $(BUILD_DIRECTORY)
	$(CC) -g -rdynamic $(INCLUDES)   $(COMPILE_FLAG)  -o $(BUILD_DIRECTORY)/pthread_race3 $(SRC_DIRECTORY)/pthread_race3.c  $(LIBS) 

pthread_term:
	@test -d $(BUILD_DIRECTORY) || mkdir $(BUILD_DIRECTORY)
	$(CC) -g -rdynamic $(INCLUDES)   $(COMPILE_FLAG)  -o $(BUILD_DIRECTORY)/pthread_term $(SRC_DIRECTORY)/pthread_term.c  $(LIBS) 

pthread_clean:
	@test -d $(BUILD_DIRECTORY) || mkdir $(BUILD_DIRECTORY)
	$(CC) -g -rdynamic $(INCLUDES)   $(COMPILE_FLAG)  -o $(BUILD_DIRECTORY)/pthread_clean $(SRC_DIRECTORY)/pthread_clean.c  $(LIBS) 

pthread_attribute:
	@test -d $(BUILD_DIRECTORY) || mkdir $(BUILD_DIRECTORY)
	$(CC) -g -rdynamic $(INCLUDES)   $(COMPILE_FLAG)  -o $(BUILD_DIRECTORY)/pthread_attribute $(SRC_DIRECTORY)/pthread_attribute.c  $(LIBS)

pthread_account:
	@test -d $(BUILD_DIRECTORY) || mkdir $(BUILD_DIRECTORY)
	$(CC) -g -rdynamic $(INCLUDES)   $(COMPILE_FLAG)  -o $(BUILD_DIRECTORY)/pthread_account $(SRC_DIRECTORY)/pthread_account.c $(SRC_DIRECTORY)/account.c $(LIBS)

pthread_account_mutex:
	@test -d $(BUILD_DIRECTORY) || mkdir $(BUILD_DIRECTORY)
	$(CC) -g -rdynamic $(INCLUDES)   $(COMPILE_FLAG)  -o $(BUILD_DIRECTORY)/pthread_account_mutex \
		$(SRC_DIRECTORY)/pthread_account_mutex.c $(SRC_DIRECTORY)/account_mutex.c $(LIBS)

pthread_mutex_type:
	@test -d $(BUILD_DIRECTORY) || mkdir $(BUILD_DIRECTORY)
	$(CC) -g -rdynamic $(INCLUDES)   $(COMPILE_FLAG)  -o $(BUILD_DIRECTORY)/pthread_mutex_type $(SRC_DIRECTORY)/pthread_mutex_type.c  $(LIBS)

pthread_rwlock:
	@test -d $(BUILD_DIRECTORY) || mkdir $(BUILD_DIRECTORY)
	$(CC) -g -rdynamic $(INCLUDES)   $(COMPILE_FLAG)  -o $(BUILD_DIRECTORY)/pthread_rwlock $(SRC_DIRECTORY)/pthread_rwlock.c  $(LIBS)

pthread_cond:
	@test -d $(BUILD_DIRECTORY) || mkdir $(BUILD_DIRECTORY)
	$(CC) -g -rdynamic $(INCLUDES)   $(COMPILE_FLAG)  -o $(BUILD_DIRECTORY)/pthread_cond $(SRC_DIRECTORY)/pthread_cond.c  $(LIBS)

pthread_cond_multi:
	@test -d $(BUILD_DIRECTORY) || mkdir $(BUILD_DIRECTORY)
	$(CC) -g -rdynamic $(INCLUDES)   $(COMPILE_FLAG)  -o $(BUILD_DIRECTORY)/pthread_cond_multi $(SRC_DIRECTORY)/pthread_cond_multi.c  $(LIBS)

pthread_productor_consumer:
	@test -d $(BUILD_DIRECTORY) || mkdir $(BUILD_DIRECTORY)
	$(CC) -g -rdynamic $(INCLUDES)   $(COMPILE_FLAG)  -o $(BUILD_DIRECTORY)/pthread_productor_consumer $(SRC_DIRECTORY)/pthread_productor_consumer.c  $(LIBS)

pthread_sem_base:
	@test -d $(BUILD_DIRECTORY) || mkdir $(BUILD_DIRECTORY)
	$(CC) -g -rdynamic $(INCLUDES)   $(COMPILE_FLAG)  -o $(BUILD_DIRECTORY)/pthread_sem_base $(SRC_DIRECTORY)/pthread_sem_base.c  $(LIBS)

pthread_account_sem:
	@test -d $(BUILD_DIRECTORY) || mkdir $(BUILD_DIRECTORY)
	$(CC) -g -rdynamic $(INCLUDES)   $(COMPILE_FLAG)  -o $(BUILD_DIRECTORY)/pthread_account_sem \
		$(SRC_DIRECTORY)/pthread_account_sem.c  $(SRC_DIRECTORY)/account_sem.c $(LIBS)

pthread_count_sem:
	@test -d $(BUILD_DIRECTORY) || mkdir $(BUILD_DIRECTORY)
	$(CC) -g -rdynamic $(INCLUDES)   $(COMPILE_FLAG)  -o $(BUILD_DIRECTORY)/pthread_count_sem $(SRC_DIRECTORY)/pthread_count_sem.c  $(LIBS)

pthread_deadlock:
	@test -d $(BUILD_DIRECTORY) || mkdir $(BUILD_DIRECTORY)
	$(CC) -g -rdynamic $(INCLUDES)   $(COMPILE_FLAG)  -o $(BUILD_DIRECTORY)/pthread_deadlock $(SRC_DIRECTORY)/pthread_deadlock.c  $(LIBS)

pthread_signal:
	@test -d $(BUILD_DIRECTORY) || mkdir $(BUILD_DIRECTORY)
	$(CC) -g -rdynamic $(INCLUDES)   $(COMPILE_FLAG)  -o $(BUILD_DIRECTORY)/pthread_signal $(SRC_DIRECTORY)/pthread_signal.c  $(LIBS)

pthread_cancel:
	@test -d $(BUILD_DIRECTORY) || mkdir $(BUILD_DIRECTORY)
	$(CC) -g -rdynamic $(INCLUDES)   $(COMPILE_FLAG)  -o $(BUILD_DIRECTORY)/pthread_cancel $(SRC_DIRECTORY)/pthread_cancel.c  $(LIBS)

clean:
	rm -rf $(BUILD_DIRECTORY)/*
	
